﻿// HSS.Interlink.ContextMenuView.cs
// ----------------------------------------------------------------------------
// Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.html)
// ----------------------------------------------------------------------------
// HighSpeed-Solutions, LLC
// Copyright (c) 2001-2010
// ----------------------------------------------------------------------------
// File:       ContextMenuView.cs
// Author:     HSS\gbanta
// Created:    07/16/2011
// Modified:   07/22/2011
// ----------------------------------------------------------------------------
using System.Windows;
using System.Windows.Controls;

namespace HSS.Interlink
{
	/// <summary>
	/// ContextMenuView
	/// </summary>
	public class ContextMenuView : ListBox
	{
		#region Constructors
		/// <summary>
		/// Constructor
		/// </summary>
		public ContextMenuView()
		{
		}
		#endregion

		/// <summary>
		/// Prepares the specified element to display the specified item.
		/// </summary>
		/// <param name="element">The element used to display the specified item.</param>
		/// <param name="item">The item to display</param>
		protected override void PrepareContainerForItemOverride(DependencyObject element, object item)
		{
			base.PrepareContainerForItemOverride(element, item);

			ContextMenuItem menuItem = item as ContextMenuItem;
			ListBoxItem listBoxItem = element as ListBoxItem;
			if (listBoxItem != null && null != menuItem)
			{
				if (!menuItem.CanExecute())
					listBoxItem.IsEnabled = false;
			}
		}
	}
}